From fff3885193b8240f4d54324d577276b00b5ca659 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 13 Mar 2004 01:54:04 +0000 Subject: [PATCH] Fix middle button pasting in the TextView (#81880, reported by Evert Sat Mar 13 02:55:51 2004 Matthias Clasen Fix middle button pasting in the TextView (#81880, reported by Evert Verhellen, patch by Paolo Borelli): * gtk/gtktextview.c (gtk_text_view_button_press_event): Retrieve the insert mark and move the cursor to it making sure of also scroll the window if needed. * gtk/gtktextbuffer.c (pre_paste_prep): Move the insert mark to the insertion point. --- ChangeLog | 12 ++++++++++++ ChangeLog.pre-2-10 | 12 ++++++++++++ ChangeLog.pre-2-4 | 12 ++++++++++++ ChangeLog.pre-2-6 | 12 ++++++++++++ ChangeLog.pre-2-8 | 12 ++++++++++++ gtk/gtktextbuffer.c | 2 ++ gtk/gtktextview.c | 19 ++++++++++++++++--- 7 files changed, 78 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4a40630ad1..b69d05e491 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Sat Mar 13 02:55:51 2004 Matthias Clasen + + Fix middle button pasting in the TextView (#81880, reported + by Evert Verhellen, patch by Paolo Borelli): + + * gtk/gtktextview.c (gtk_text_view_button_press_event): Retrieve + the insert mark and move the cursor to it making sure of also + scroll the window if needed. + + * gtk/gtktextbuffer.c (pre_paste_prep): Move the insert mark + to the insertion point. + Sat Mar 13 01:38:55 2004 Matthias Clasen * gtk/gtkcombobox.c (gtk_combo_box_remove): Add a remove diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 4a40630ad1..b69d05e491 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,15 @@ +Sat Mar 13 02:55:51 2004 Matthias Clasen + + Fix middle button pasting in the TextView (#81880, reported + by Evert Verhellen, patch by Paolo Borelli): + + * gtk/gtktextview.c (gtk_text_view_button_press_event): Retrieve + the insert mark and move the cursor to it making sure of also + scroll the window if needed. + + * gtk/gtktextbuffer.c (pre_paste_prep): Move the insert mark + to the insertion point. + Sat Mar 13 01:38:55 2004 Matthias Clasen * gtk/gtkcombobox.c (gtk_combo_box_remove): Add a remove diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 4a40630ad1..b69d05e491 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,15 @@ +Sat Mar 13 02:55:51 2004 Matthias Clasen + + Fix middle button pasting in the TextView (#81880, reported + by Evert Verhellen, patch by Paolo Borelli): + + * gtk/gtktextview.c (gtk_text_view_button_press_event): Retrieve + the insert mark and move the cursor to it making sure of also + scroll the window if needed. + + * gtk/gtktextbuffer.c (pre_paste_prep): Move the insert mark + to the insertion point. + Sat Mar 13 01:38:55 2004 Matthias Clasen * gtk/gtkcombobox.c (gtk_combo_box_remove): Add a remove diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 4a40630ad1..b69d05e491 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,15 @@ +Sat Mar 13 02:55:51 2004 Matthias Clasen + + Fix middle button pasting in the TextView (#81880, reported + by Evert Verhellen, patch by Paolo Borelli): + + * gtk/gtktextview.c (gtk_text_view_button_press_event): Retrieve + the insert mark and move the cursor to it making sure of also + scroll the window if needed. + + * gtk/gtktextbuffer.c (pre_paste_prep): Move the insert mark + to the insertion point. + Sat Mar 13 01:38:55 2004 Matthias Clasen * gtk/gtkcombobox.c (gtk_combo_box_remove): Add a remove diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 4a40630ad1..b69d05e491 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,15 @@ +Sat Mar 13 02:55:51 2004 Matthias Clasen + + Fix middle button pasting in the TextView (#81880, reported + by Evert Verhellen, patch by Paolo Borelli): + + * gtk/gtktextview.c (gtk_text_view_button_press_event): Retrieve + the insert mark and move the cursor to it making sure of also + scroll the window if needed. + + * gtk/gtktextbuffer.c (pre_paste_prep): Move the insert mark + to the insertion point. + Sat Mar 13 01:38:55 2004 Matthias Clasen * gtk/gtkcombobox.c (gtk_combo_box_remove): Add a remove diff --git a/gtk/gtktextbuffer.c b/gtk/gtktextbuffer.c index b327d50f2f..0a9f947451 100644 --- a/gtk/gtktextbuffer.c +++ b/gtk/gtktextbuffer.c @@ -2936,6 +2936,8 @@ pre_paste_prep (ClipboardRequest *request_data, if (gtk_text_buffer_get_selection_bounds (buffer, &start, &end)) *insert_point = start; } + + gtk_text_buffer_move_mark_by_name (buffer, "insert", insert_point); } static void diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index df8d877800..a501ecd855 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -3931,6 +3931,7 @@ gtk_text_view_button_press_event (GtkWidget *widget, GdkEventButton *event) else if (event->button == 2) { GtkTextIter iter; + GtkTextMark *mark; gtk_text_layout_get_iter_at_pixel (text_view->layout, &iter, @@ -3938,9 +3939,21 @@ gtk_text_view_button_press_event (GtkWidget *widget, GdkEventButton *event) event->y + text_view->yoffset); gtk_text_buffer_paste_clipboard (get_buffer (text_view), - gtk_widget_get_clipboard (widget, GDK_SELECTION_PRIMARY), - &iter, - text_view->editable); + gtk_widget_get_clipboard (widget, GDK_SELECTION_PRIMARY), + &iter, + text_view->editable); + + mark = gtk_text_buffer_get_mark (get_buffer (text_view), "insert"); + gtk_text_buffer_get_iter_at_mark (get_buffer (text_view), + &iter, + mark); + + gtk_text_buffer_place_cursor (get_buffer (text_view), &iter); + + DV(g_print (G_STRLOC": scrolling onscreen\n")); + gtk_text_view_scroll_mark_onscreen (text_view, + gtk_text_buffer_get_mark (get_buffer (text_view), + "insert")); return TRUE; } else if (event->button == 3) -- 2.30.2